#include "Common.h"
#include "AudioDevice.h"
#include "Pedal.h"
#include "AudioSource.h"
#include "AudioRenderer.h"

namespace VirtualPedal
{

TweakablePropertyInfo::TweakablePropertyInfo(System::Reflection::PropertyInfo^ propInfo, TweakablePropertyAttribute^ attr)
{
	m_PropertyInfo = propInfo;
	MinValue = attr->MinValue;
	MaxValue = attr->MaxValue;
	DefaultValue = attr->DefaultValue;
}

void TweakablePropertyInfo::SetValue(PedalBase^ owner, float value)
{
	value = Math::Max(MinValue, Math::Min(MaxValue, value));
	if(GetValue(owner) != value)
	{
		m_PropertyInfo->SetValue(owner, value, nullptr);
		owner->OnTweakablePropertyChanged();
	}
}

float TweakablePropertyInfo::GetValue(PedalBase^ owner)
{
	return (float)m_PropertyInfo->GetValue(owner, nullptr);
}

}